package com.google.android.material.bottomnavigation;

import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable.ClassLoaderCreator;
import android.os.Parcelable.Creator;
import android.util.AttributeSet;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.FrameLayout;
import androidx.annotation.DimenRes;
import androidx.annotation.Dimension;
import androidx.annotation.DrawableRes;
import androidx.annotation.IdRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StyleRes;
import androidx.core.view.ViewCompat;
import androidx.customview.view.AbsSavedState;
import o.aqu.b;
import o.aqu.c;
import o.aqu.f;
import o.aqu.n;
import o.arb;
import o.asa;
import o.az;
import o.bd;
import o.cw;
import o.fo;

public class BottomNavigationView extends FrameLayout {
    private d ʼ;
    private e ˊ;
    private MenuInflater ˋ;
    private final bd ˎ;
    private final BottomNavigationMenuView ˏ;
    private final BottomNavigationPresenter ॱ;

    static class SavedState extends AbsSavedState {
        public static final Creator<SavedState> CREATOR = new ClassLoaderCreator<SavedState>() {
            public /* synthetic */ Object createFromParcel(Parcel parcel) {
                return ˏ(parcel);
            }

            public /* synthetic */ Object createFromParcel(Parcel parcel, ClassLoader classLoader) {
                return ˏ(parcel, classLoader);
            }

            public /* synthetic */ Object[] newArray(int i) {
                return ˋ(i);
            }

            public SavedState ˏ(Parcel parcel, ClassLoader classLoader) {
                return new SavedState(parcel, classLoader);
            }

            public SavedState ˏ(Parcel parcel) {
                return new SavedState(parcel, null);
            }

            public SavedState[] ˋ(int i) {
                return new SavedState[i];
            }
        };
        Bundle ˎ;

        public SavedState(Parcelable parcelable) {
            super(parcelable);
        }

        public SavedState(Parcel parcel, ClassLoader classLoader) {
            super(parcel, classLoader);
            ˊ(parcel, classLoader);
        }

        public void writeToParcel(@NonNull Parcel parcel, int i) {
            super.writeToParcel(parcel, i);
            parcel.writeBundle(this.ˎ);
        }

        private void ˊ(Parcel parcel, ClassLoader classLoader) {
            this.ˎ = parcel.readBundle(classLoader);
        }
    }

    public interface d {
        void ˊ(@NonNull MenuItem menuItem);
    }

    public interface e {
        boolean ˋ(@NonNull MenuItem menuItem);
    }

    public BottomNavigationView(Context context) {
        this(context, null);
    }

    public BottomNavigationView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, o.aqu.d.ˎ);
    }

    public BottomNavigationView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.ॱ = new BottomNavigationPresenter();
        this.ˎ = new arb(context);
        this.ˏ = new BottomNavigationMenuView(context);
        LayoutParams layoutParams = new FrameLayout.LayoutParams(-2, -2);
        layoutParams.gravity = 17;
        this.ˏ.setLayoutParams(layoutParams);
        this.ॱ.ॱ(this.ˏ);
        this.ॱ.ˊ(1);
        this.ˏ.setPresenter(this.ॱ);
        this.ˎ.ˊ(this.ॱ);
        this.ॱ.ˏ(getContext(), this.ˎ);
        cw ˏ = asa.ˏ(context, attributeSet, n.ˊˊ, i, f.ʻ, n.ˋˋ, n.ˎˎ);
        if (ˏ.ᐝ(n.ˏˏ)) {
            this.ˏ.setIconTintList(ˏ.ॱ(n.ˏˏ));
        } else {
            this.ˏ.setIconTintList(this.ˏ.ˎ(16842808));
        }
        setItemIconSize(ˏ.ˎ(n.ˋᐝ, getResources().getDimensionPixelSize(c.ˊ)));
        if (ˏ.ᐝ(n.ˋˋ)) {
            setItemTextAppearanceInactive(ˏ.ॱॱ(n.ˋˋ, 0));
        }
        if (ˏ.ᐝ(n.ˎˎ)) {
            setItemTextAppearanceActive(ˏ.ॱॱ(n.ˎˎ, 0));
        }
        if (ˏ.ᐝ(n.ͺॱ)) {
            setItemTextColor(ˏ.ॱ(n.ͺॱ));
        }
        if (ˏ.ᐝ(n.ˌ)) {
            ViewCompat.ˋ(this, (float) ˏ.ˎ(n.ˌ, 0));
        }
        setLabelVisibilityMode(ˏ.ˏ(n.ˍ, -1));
        setItemHorizontalTranslationEnabled(ˏ.ˋ(n.ˏˎ, true));
        this.ˏ.setItemBackgroundRes(ˏ.ॱॱ(n.ˑ, 0));
        if (ˏ.ᐝ(n.ˎˏ)) {
            ˋ(ˏ.ॱॱ(n.ˎˏ, 0));
        }
        ˏ.ॱ();
        addView(this.ˏ, layoutParams);
        if (VERSION.SDK_INT < 21) {
            ˊ(context);
        }
        this.ˎ.ॱ(new o.bd.e(this) {
            final /* synthetic */ BottomNavigationView ॱ;

            {
                this.ॱ = r1;
            }

            public boolean ॱ(bd bdVar, MenuItem menuItem) {
                if (this.ॱ.ʼ != null && menuItem.getItemId() == this.ॱ.ˊ()) {
                    this.ॱ.ʼ.ˊ(menuItem);
                    return true;
                } else if (this.ॱ.ˊ == null || this.ॱ.ˊ.ˋ(menuItem)) {
                    return false;
                } else {
                    return true;
                }
            }

            public void ˎ(bd bdVar) {
            }
        });
    }

    public void setOnNavigationItemSelectedListener(@Nullable e eVar) {
        this.ˊ = eVar;
    }

    public void setOnNavigationItemReselectedListener(@Nullable d dVar) {
        this.ʼ = dVar;
    }

    public void ˋ(int i) {
        this.ॱ.ˎ(true);
        ˏ().inflate(i, this.ˎ);
        this.ॱ.ˎ(false);
        this.ॱ.ˊ(true);
    }

    public void setItemIconTintList(@Nullable ColorStateList colorStateList) {
        this.ˏ.setIconTintList(colorStateList);
    }

    public void setItemIconSize(@Dimension int i) {
        this.ˏ.setItemIconSize(i);
    }

    public void setItemIconSizeRes(@DimenRes int i) {
        setItemIconSize(getResources().getDimensionPixelSize(i));
    }

    public void setItemTextColor(@Nullable ColorStateList colorStateList) {
        this.ˏ.setItemTextColor(colorStateList);
    }

    public void setItemBackgroundResource(@DrawableRes int i) {
        this.ˏ.setItemBackgroundRes(i);
    }

    public void setItemBackground(@Nullable Drawable drawable) {
        this.ˏ.setItemBackground(drawable);
    }

    @IdRes
    public int ˊ() {
        return this.ˏ.ˎ();
    }

    public void setSelectedItemId(@IdRes int i) {
        MenuItem findItem = this.ˎ.findItem(i);
        if (findItem != null && !this.ˎ.ˊ(findItem, this.ॱ, 0)) {
            findItem.setChecked(true);
        }
    }

    public void setLabelVisibilityMode(int i) {
        if (this.ˏ.ॱ() != i) {
            this.ˏ.setLabelVisibilityMode(i);
            this.ॱ.ˊ(false);
        }
    }

    public void setItemTextAppearanceInactive(@StyleRes int i) {
        this.ˏ.setItemTextAppearanceInactive(i);
    }

    public void setItemTextAppearanceActive(@StyleRes int i) {
        this.ˏ.setItemTextAppearanceActive(i);
    }

    public void setItemHorizontalTranslationEnabled(boolean z) {
        if (this.ˏ.ˋ() != z) {
            this.ˏ.setItemHorizontalTranslationEnabled(z);
            this.ॱ.ˊ(false);
        }
    }

    private void ˊ(Context context) {
        View view = new View(context);
        view.setBackgroundColor(fo.ˋ(context, b.ˎ));
        view.setLayoutParams(new FrameLayout.LayoutParams(-1, getResources().getDimensionPixelSize(c.ʼ)));
        addView(view);
    }

    private MenuInflater ˏ() {
        if (this.ˋ == null) {
            this.ˋ = new az(getContext());
        }
        return this.ˋ;
    }

    protected Parcelable onSaveInstanceState() {
        Parcelable savedState = new SavedState(super.onSaveInstanceState());
        savedState.ˎ = new Bundle();
        this.ˎ.ˏ(savedState.ˎ);
        return savedState;
    }

    protected void onRestoreInstanceState(Parcelable parcelable) {
        if (parcelable instanceof SavedState) {
            SavedState savedState = (SavedState) parcelable;
            super.onRestoreInstanceState(savedState.ˊ());
            this.ˎ.ˋ(savedState.ˎ);
            return;
        }
        super.onRestoreInstanceState(parcelable);
    }
}
